package web;/**
 * Created by aiqinag on 2017-06-23.
 */

import biz.Smbms_BillBiz;
import entity.Smbms_Bill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 订单
 *
 * @author tom_plus
 * @date 2017-06-23-9:52
 */
@Controller
@RequestMapping("/bill")

@SessionAttributes(types = Smbms_Bill.class)
public class Smbms_BillWeb {

    @Autowired
    private Smbms_BillBiz billBiz;


    /**  查询所有关联bill的信息 */
    @RequestMapping("showBill")
    public String selectBill(Model model){
        List<Smbms_Bill> Listbill = this.billBiz.selectBill();

        model.addAttribute("billList",Listbill);
        return "jsp/billlist";
    }

    /** 删除bill的信息*/
    @RequestMapping("deleteBill")
    @ResponseBody
    public Map deleteBill(HttpServletRequest request) throws IOException {

       // response.setContentType("application/json");
        //PrintWriter out = response.getWriter();
        System.out.println("进入删除方法！"+request.getParameter("billid")+request.getParameter("billcc"));
        String delId = request.getParameter("billid");
        int boo = this.billBiz.deleteBill(delId);
        System.out.println("------------------"+boo);
       //out.println("{\"flag\":true}");
        //return "{\"flag\":true}";
        Map map = new HashMap();
        map.put("flag",true);
        return map;
    }

    @RequestMapping("billView")
    public String billView(String billid, Model model){
        System.out.println(billid+"  11111111111111111");
        return "/jsp/billlist";
    }

}
